<template>
  <div class="page-container">
    <div class="title">Pagination 分页</div>
    <div class="desc">当数据量过多时，使用分页分解数据。</div>
    <p class="item-title">页数少时的效果</p>
    <div class="page-item">
      <jhb-pagination
        :current-page.sync="currentPage1"
        :page-size="8"
        :page-sizes="[5, 10, 20, 30, 40]"
        :total="36"
        layout="prev, pager, next, total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      >
      </jhb-pagination>
    </div>
    
    <p class="item-title">大于7页时的效果</p>
    <div class="page-item">
      <jhb-pagination
        current-page.sync="6"
        :page-size="2"
        :page-sizes="[5, 10, 20, 30, 40]"
        :total="36"
        layout="prev, pager, next, total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      >
      </jhb-pagination>
    </div>

    <p class="item-title">调整每页显示条数</p>
    <div class="page-item">
      <jhb-pagination
        current-page.sync="6"
        :page-size="2"
        :page-sizes="[2, 10, 20, 30, 40]"
        :total="36"
        layout="prev, pager, next, sizes, total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      >
      </jhb-pagination>
    </div>

    <p class="item-title">直接去</p>
    <div class="page-item">
      <jhb-pagination
        current-page.sync="6"
        :page-size="2"
        :page-sizes="[2, 10, 20, 30, 40]"
        :total="36"
        layout="prev, pager, next, jumper, total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      >
      </jhb-pagination>
    </div>

    <p class="item-title">完整功能</p>
    <div class="page-item">
      <jhb-pagination
        current-page.sync="6"
        :page-size="2"
        :page-sizes="[2, 10, 20, 30, 40]"
        :total="36"
        layout="prev, pager, next, sizes, jumper, total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      >
      </jhb-pagination>
    </div>
  </div>
</template>
<script>
import jhbPagination from "pkgs/JHB-pagination/src";
export default {
  components: {
    jhbPagination
  },
  data() {
    return {
      currentPage1: 1
    };
  },
  mounted() {
    const nodeArr = document.getElementsByClassName("el-pagination__jump");
    Array.prototype.forEach.call(nodeArr, item => {
      item.childNodes[0].nodeValue = "去"
    })
  },
  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
  },
};
</script>

<style lang="scss" scoped>
  .page-container {
    display: flex;
    flex-direction: column;
    .title {
      font-size: 28px;
      font-weight: 400;
      color: #1f2f3d;
    }
    .desc {
      font-size: 14px;
      color: #5e6d82;
      padding: 14px 0;
      border-bottom: 1px solid #ebebeb;
      margin-bottom: 20px;
    }
    .item-title {
      font-size: 20px;
      margin: 26px 0;
      font-weight: 400;
      color: #1f2f3d;
    }
    .item-title:first-child {
      margin-top: 0;
    }
    .page-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
  }
</style>
